package com.hdax.dmw.order.api;

import com.hdax.dmw.common.utils.Result;
import com.hdax.dmw.order.service.OrderService;
import com.hdax.dmw.order.vo.SubmitOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping(path = "/order/p/")
public class SubmitOrderApi {

    @Autowired
    private OrderService orderService;

    @PostMapping(path = "/submitorder")
    public Result<Map<String,String>> submitOrder(@RequestBody SubmitOrderVo vo,
                                                  HttpServletRequest request){
        String token = request.getHeader("token");
        return orderService.submitOrder(vo,token);
    }
}
